<?php

class Admin_RoomsController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
    	echo "This is rooms controller";exit;
       $this->_helper->layout->setLayout('admin');	
       Zend_Loader::loadFile('../application/admin/models/Newsletter.php');
       $rooms_model = new rooms();
       $rooms_arr = $rooms_model->listroomss();
       // print_r($rooms_arr); EXIT;
       $this->view->rooms_arr = $rooms_arr;
     
    }
    
    public function addAction()
    {
        $this->_helper->layout->setLayout('admin');	
		Zend_Loader::loadFile('../application/admin/forms/rooms.php');
        $rooms_form = new Form_rooms();
        $this->view->title = "Add new News Letter";
        
        $this->view->rooms_form = $rooms_form;
        
        if ($this->getRequest()->isPost()) {
            $formData = $this->getRequest()->getPost();
            if ($rooms_form->isValid($formData)) {
                $rooms_title = $rooms_form->getValue('rooms_title');
                $rooms_content = $rooms_form->getValue('rooms_content');
                $template_id = $rooms_form->getValue('template_id');
           Zend_Loader::loadFile('../application/admin/models/rooms.php');
           $rooms_model = new rooms();
           $rooms_model->addrooms($template_id,$rooms_title, $rooms_content);
           $this->_helper->redirector('index');
            } else {
                $rooms_form->populate($formData);
            }
        }
            
    }

    public function editAction()
    {
    	$this->_helper->layout->setLayout('admin');	
        Zend_Loader::loadFile('../application/admin/forms/rooms.php');
        $rooms_form = new Form_rooms();
        $this->view->form = $rooms_form;
        
        if ($this->getRequest()->isPost()) {
            $formData = $this->getRequest()->getPost();
            if ($rooms_form->isValid($formData)) {
                $rooms_id = (int)$rooms_form->getValue('rooms_id');
                $rooms_title = $rooms_form->getValue('rooms_title');
                $rooms_content = $rooms_form->getValue('rooms_content');
                $template_id = $rooms_form->getValue('template_id');
                Zend_Loader::loadFile('../application/admin/models/rooms.php');
                $rooms_model = new rooms();
                $rooms_model->updaterooms($rooms_id, $rooms_title, $rooms_content,$template_id);
                
                $this->_helper->redirector('index');
            } else {
                $form->populate($formData);
            }
        } else {
            $rooms_id = $this->_getParam('rooms_id', 0);
            if ($rooms_id > 0) {
                Zend_Loader::loadFile('../application/admin/models/rooms.php');
                $rooms_model = new rooms();
                $rooms_form->populate($rooms_model->getrooms($rooms_id));
            }
        }
        
    }

    /*public function deleteAction()
    {
      $this->_helper->layout->setLayout('admin');	
        if ($this->getRequest()->isPost()) {
            $del = $this->getRequest()->getPost('del');
            if ($del == 'Yes') {
               $rooms_id = $this->getRequest()->getPost('id');
                Zend_Loader::loadFile('../application/admin/models/rooms.php');
                $rooms_model = new rooms();
                $rooms_model->deleterooms($rooms_id);
            }
            $this->_helper->redirector('index');
        } else {
            $rooms_id = $this->_getParam('rooms_id', 0);
            Zend_Loader::loadFile('../application/admin/models/rooms.php');
            $rooms_model = new rooms();
            $this->view->rooms = $rooms_model->getrooms($rooms_id);
        }
    }*/
    
      public function deleteAction()
          {
               $this->_helper->layout->setLayout('admin');	
               $rooms_id = $this->_getParam('rooms_id', 0);
           //    echo $hotel_id;exit;
                Zend_Loader::loadFile('../application/admin/models/rooms.php');
                $rooms_model = new rooms();
                $rooms_model->deleterooms($rooms_id);
                 $this->_helper->redirector('index');
      
       
           }


}







